home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / INETDEVI.{9D < prev    next >
Text File  |  1999-09-17  |  4KB  |  127 lines

  1. #ifndef _LINUX_INETDEVICE_H
  2. #define _LINUX_INETDEVICE_H
  3.  
  4. #ifdef __KERNEL__
  5.  
  6. struct ipv4_devconf
  7. {
  8.     int    accept_redirects;
  9.     int    send_redirects;
  10.     int    secure_redirects;
  11.     int    shared_media;
  12.     int    accept_source_route;
  13.     int    rp_filter;
  14.     int    proxy_arp;
  15.     int    bootp_relay;
  16.     int    log_martians;
  17.     int    forwarding;
  18.     int    mc_forwarding;
  19.     void    *sysctl;
  20. };
  21.  
  22. extern struct ipv4_devconf ipv4_devconf;
  23.  
  24. struct in_device
  25. {
  26.     struct device        *dev;
  27.     struct in_ifaddr    *ifa_list;    /* IP ifaddr chain        */
  28.     struct ip_mc_list    *mc_list;    /* IP multicast filter chain    */
  29.     unsigned long        mr_v1_seen;
  30.     unsigned        flags;
  31.     struct neigh_parms    *arp_parms;
  32.     struct ipv4_devconf    cnf;
  33. };
  34.  
  35. #define IN_DEV_FORWARD(in_dev)        ((in_dev)->cnf.forwarding)
  36. #define IN_DEV_MFORWARD(in_dev)        (ipv4_devconf.mc_forwarding && (in_dev)->cnf.mc_forwarding)
  37. #define IN_DEV_RPFILTER(in_dev)        (ipv4_devconf.rp_filter && (in_dev)->cnf.rp_filter)
  38. #define IN_DEV_SOURCE_ROUTE(in_dev)    (ipv4_devconf.accept_source_route && (in_dev)->cnf.accept_source_route)
  39. #define IN_DEV_BOOTP_RELAY(in_dev)    (ipv4_devconf.bootp_relay && (in_dev)->cnf.bootp_relay)
  40.  
  41. #define IN_DEV_LOG_MARTIANS(in_dev)    (ipv4_devconf.log_martians || (in_dev)->cnf.log_martians)
  42. #define IN_DEV_PROXY_ARP(in_dev)    (ipv4_devconf.proxy_arp || (in_dev)->cnf.proxy_arp)
  43. #define IN_DEV_SHARED_MEDIA(in_dev)    (ipv4_devconf.shared_media || (in_dev)->cnf.shared_media)
  44. #define IN_DEV_TX_REDIRECTS(in_dev)    (ipv4_devconf.send_redirects || (in_dev)->cnf.send_redirects)
  45. #define IN_DEV_SEC_REDIRECTS(in_dev)    (ipv4_devconf.secure_redirects || (in_dev)->cnf.secure_redirects)
  46.  
  47. #define IN_DEV_RX_REDIRECTS(in_dev) \
  48.     ((IN_DEV_FORWARD(in_dev) && \
  49.       (ipv4_devconf.accept_redirects && (in_dev)->cnf.accept_redirects)) \
  50.      || (!IN_DEV_FORWARD(in_dev) && \
  51.       (ipv4_devconf.accept_redirects || (in_dev)->cnf.accept_redirects)))
  52.  
  53. struct in_ifaddr
  54. {
  55.     struct in_ifaddr    *ifa_next;
  56.     struct in_device    *ifa_dev;
  57.     u32            ifa_local;
  58.     u32            ifa_address;
  59.     u32            ifa_mask;
  60.     u32            ifa_broadcast;
  61.     u32            ifa_anycast;
  62.     unsigned char        ifa_scope;
  63.     unsigned char        ifa_flags;
  64.     unsigned char        ifa_prefixlen;
  65.     char            ifa_label[IFNAMSIZ];
  66. };
  67.  
  68. extern int register_inetaddr_notifier(struct notifier_block *nb);
  69. extern int unregister_inetaddr_notifier(struct notifier_block *nb);
  70.  
  71. extern struct device     *ip_dev_find(u32 addr);
  72. extern struct in_ifaddr    *inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b);
  73. extern int        devinet_ioctl(unsigned int cmd, void *);
  74. extern void        devinet_init(void);
  75. extern struct in_device *inetdev_init(struct device *dev);
  76. extern struct in_device    *inetdev_by_index(int);
  77. extern u32        inet_select_addr(struct device *dev, u32 dst, int scope);
  78. extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, u32 mask);
  79. extern void        inet_forward_change(void);
  80.  
  81. extern __inline__ int inet_ifa_match(u32 addr, struct in_ifaddr *ifa)
  82. {
  83.     return !((addr^ifa->ifa_address)&ifa->ifa_mask);
  84. }
  85.  
  86. /*
  87.  *    Check if a mask is acceptable.
  88.  */
  89.  
  90. extern __inline__ int bad_mask(u32 mask, u32 addr)
  91. {
  92.     if (addr & (mask = ~mask))
  93.         return 1;
  94.     mask = ntohl(mask);
  95.     if (mask & (mask+1))
  96.         return 1;
  97.     return 0;
  98. }
  99.  
  100. #define for_primary_ifa(in_dev)    { struct in_ifaddr *ifa; \
  101.   for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next)
  102.  
  103. #define for_ifa(in_dev)    { struct in_ifaddr *ifa; \
  104.   for (ifa = (in_dev)->ifa_list; ifa; ifa = ifa->ifa_next)
  105.  
  106.  
  107. #define endfor_ifa(in_dev) }
  108.  
  109. #endif /* __KERNEL__ */
  110.  
  111. extern __inline__ __u32 inet_make_mask(int logmask)
  112. {
  113.     if (logmask)
  114.         return htonl(~((1<<(32-logmask))-1));
  115.     return 0;
  116. }
  117.  
  118. extern __inline__ int inet_mask_len(__u32 mask)
  119. {
  120.     if (!(mask = ntohl(mask)))
  121.         return 0;
  122.     return 32 - ffz(~mask);
  123. }
  124.  
  125.  
  126. #endif /* _LINUX_INETDEVICE_H */
  127.